import yagmail

def mail(user,password,host,to,subject,contents):
    # user发件人->password密码-> host:SMTP服务器地址(QQ邮箱使用 'smtp.qq.com')
    # 创建 SMTP 连接
    Mail=yagmail.SMTP(user=user,
                      password=password,
                      host=host)
    # to: 收件人邮箱地址 -> subject: 邮件主题 -> contents: 邮件内容
    Mail.send(to=to,
              subject=subject,
              contents=contents)